package com.dotflat.fin.cnst;

import com.dotflat.fin.utils.excelUtil.StringUtils;

/**
 * 产品单位常量
 * @date ：Created in 11/6/2020 3:15 PM
 */
public enum ProductUnitEnum {
    DAY(1,  0, 1,"天"),
    WEEK(2, 0, 7, "周"),
    MONTH(3, 1, 0, "月"),
    HALFYEAR(4, 6, 0,"半年"),
    YEAR(5,12, 0, "年");


    private Integer code;
    private Integer month;
    private Integer day;

    private String value;

    ProductUnitEnum(Integer code, Integer month, Integer day, String value) {
        this.code = code;
        this.month = month;
        this.day = day;
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    public Integer getCode() {
        return code;
    }

    public Integer getMonth() {
        return month;
    }

    public Integer getDay() {
        return day;
    }

    public static ProductUnitEnum get(Integer code){
        if (code == null){
            return null;
        }

        for (ProductUnitEnum t : values() ) {
            if (t.getCode() == code)
                return t;
        }
        return null;
    }

    public static ProductUnitEnum get(String value){
        if (value == null){
            return null;
        }

        for (ProductUnitEnum t : values() ) {
            if (t.getValue().equals(value))
                return t;
        }
        return null;
    }
}
